<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/jquery-3.2.1.min.js"></script>
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
</head>
<body>
<div class="x-body" >
    <form class="layui-form" >
        <div class="layui-form-item">
            <label for="managerName" class="layui-form-label">
                <span class="x-red">*</span>经理名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerName"  name="managerName"  required="" lay-verify=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="managerNickName" class="layui-form-label">
                <span class="x-red">*</span>昵称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerNickName"  name="managerNickName"  required="" lay-verify=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="managerPWd" class="layui-form-label">
                <span class="x-red">*</span>密码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerPWd"  name="managerPwd"  required="" lay-verify=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="managerSex" class="layui-form-label">
                <span class="x-red">*</span>性别
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerSex"  name="managerSex"  required="" lay-verify=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="managerBirth" class="layui-form-label">
                <span class="x-red">*</span>出生日期
            </label>
            <div class="layui-input-inline">
                <input type="date" id="managerBirth"  name="managerBirth"  required="" lay-verify=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="managerTel" class="layui-form-label">
                <span class="x-red">*</span>电话
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerTel"  name="managerTel"  required="" lay-verify=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="managerEmail" class="layui-form-label">
                <span class="x-red">*</span>邮箱
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerEmail"  name="managerEmail"  required="" lay-verify=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="managerEdu" class="layui-form-label">
                <span class="x-red">*</span>学历
            </label>
            <div class="layui-input-inline" style="width: 190px;height: 40px" >
                <select name="managerEdu" id="managerEdu" >
                    <option value="小学">小学</option>
                    <option value="初中">初中</option>
                    <option value="高中">高中</option>
                    <option value="本科">本科</option>
                    <option value="硕士">硕士</option>
                    <option value="博士">博士</option>
                </select>
            </div>

        </div>
        <div class="layui-form-item">
            <label for="managerIdCard" class="layui-form-label">
                <span class="x-red">*</span>身份证号码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerIdCard"  name="managerIdCard"  required="" lay-verify=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="managerRightLevel" class="layui-form-label">
                <span class="x-red">*</span>权限等级
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerRightLevel"  disabled   name="managerRightLevel" th:value="一级权限" required="" lay-verify=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="managerText" class="layui-form-label">
                <span class="x-red">*</span>备注
            </label>
            <div class="layui-input-inline">
                <input type="text" id="managerText"  name="managerText"  required="" lay-verify=""
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                新增
            </button>
        </div>
        <span id="info" style="color:red"></span>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            managerName: function(value){
                if(value.length < 5){
                    return '昵称至少得5个字符啊';
                }
            }
        });

        //修改
        form.on('submit(add)', function(data){
            console.log(data);
            $.ajax({
                url:"/manager-manager/xinjian",
                type:"post",
                data:data.field,
                dataType:"json",//返回的数据类型
                success:function(data){
                    //定义{info:"新建成功"}
                    $("#info").text(data.info);

                    if(data.info=="新建成功"){
                        //关闭弹窗
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        //刷新
                        parent.window.location.href=parent.window.location.href;

                    }


                }

            })
            return false;
        });


    });
</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>
</html>
<script>
    //新建方法
    function xinjian() {
        //获取输入数据
        var photo =$("#managerPhoto").val();
        var name =$("#managerName").val();
        var sex =$("#managerSex").val();
        var birth =$("#managerBirth").val();
        var tel =$("#managerTel").val();
        var email=$("#managerEmail").val();
        var edu=$("#managerEdu").val();
        var idcard=$("#managerIdCard").val();
        var mtext=$("#managerText").val();
        $.ajax({
            url:"/manager/xinjian",
            type:"post",
            data:{"managerName":name,"managerPhoto":photo,"managerSex":sex,"managerBirth":birth,"managerTel":tel,"managerEmail":email,"managerEdu":edu,"managerIdCard":idcard,"managerText":mtext},
            dataType:"json",//返回的数据类型
            success:function(data){
                //定义{info:"新建成功"}
                $("#info").text(data.info);
                if(data.info=="新建成功"){
                    //关闭弹窗
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    //刷新
                    parent.window.location.href=parent.window.location.href;

                }


            }

        })
    }
</script>